 package handling.world;

 import client.MapleCharacter;
 import handling.channel.ChannelServer;
 import java.util.Iterator;
 import java.util.List;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;








 public class WorldBroadcastService
 {
/*  19 */   private static final Logger log = LogManager.getLogger(WorldBroadcastService.class.getName());

   private WorldBroadcastService() {
/*  22 */     log.info("正在启动[WorldBroadcastService]");
   }

   public static WorldBroadcastService getInstance() {
/*  26 */     return SingletonHolder.instance;
   }

   public void broadcastSmega(byte[] message) {
/*  30 */     for (ChannelServer cs : ChannelServer.getAllInstances()) {
/*  31 */       cs.broadcastSmega(message);
     }
   }

   public void broadcastGMMessage(byte[] message) {
/*  36 */     for (ChannelServer cs : ChannelServer.getAllInstances()) {
/*  37 */       cs.broadcastGMMessage(message);
     }
   }

   public void broadcastMessage(byte[] message) {
/*  42 */     for (ChannelServer cs : ChannelServer.getAllInstances()) {
/*  43 */       cs.broadcastMessage(message);
     }
   }


   public void sendPacket(List<Integer> targetIds, byte[] packet, int exception) {
/*  49 */     for (Iterator<Integer> iterator = targetIds.iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/*  50 */       if (i == exception) {
         continue;
       }
/*  53 */       int ch = WorldFindService.getInstance().findChannel(i);
/*  54 */       if (ch < 0) {
         continue;
       }
/*  57 */       MapleCharacter chr = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(i);
/*  58 */       if (chr != null) {
/*  59 */         chr.send(packet);
       } }

   }

   public void sendPacket(int targetId, byte[] packet) {
/*  65 */     int ch = WorldFindService.getInstance().findChannel(targetId);
/*  66 */     if (ch < 0) {
       return;
     }
/*  69 */     MapleCharacter chr = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(targetId);
/*  70 */     if (chr != null) {
/*  71 */       chr.send(packet);
     }
   }

   public void sendGuildPacket(int targetIds, byte[] packet, int exception, int guildid, boolean chat) {
/*  76 */     if (targetIds == exception && !chat) {
       return;
     }
/*  79 */     int ch = WorldFindService.getInstance().findChannel(targetIds);
/*  80 */     if (ch < 0) {
       return;
     }
/*  83 */     MapleCharacter chr = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(targetIds);
/*  84 */     if (chr != null && chr.getGuildId() == guildid) {
/*  85 */       if (chat) {
/*  86 */         if (chr.getChatSession() != null) {
/*  87 */           chr.getChatSession().writeAndFlush(packet);
         }
       } else {
/*  90 */         chr.send(packet);
       }
     }
   }

   public void sendFamilyPacket(int targetIds, byte[] packet, int exception, int guildid) {
/*  96 */     if (targetIds == exception) {
       return;
     }
/*  99 */     int ch = WorldFindService.getInstance().findChannel(targetIds);
/* 100 */     if (ch < 0) {
       return;
     }
/* 103 */     MapleCharacter chr = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(targetIds);
/* 104 */     if (chr != null && chr.getFamilyId() == guildid) {
/* 105 */       chr.send(packet);
     }
   }




   public void startMapEffect(String msg, int itemId) {
/* 113 */     for (ChannelServer cs : ChannelServer.getAllInstances()) {
/* 114 */       cs.startMapEffect(msg, itemId);
     }
   }

   public void startMapEffect(String msg, int itemId, int time) {
/* 119 */     for (ChannelServer cs : ChannelServer.getAllInstances()) {
/* 120 */       cs.startMapEffect(msg, itemId, time);
     }
   }

   private static class SingletonHolder
   {
/* 126 */     protected static final WorldBroadcastService instance = new WorldBroadcastService();
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\world\WorldBroadcastService.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */